package flags

import (
	"flag"
)

type Flags struct {
	Hosts        string
	Port         int
	Username     string
	Password     string
	Cmds         string
	ConfigFile   string
	Key          string
	Ciphers      string
	KeyExchanges string
	LinuxMode    bool
	Timeout      int
}

var f *Flags

func FlagArgs() {
	hosts := flag.String("h", "127.0.0.1", "host address")
	port := flag.Int("P", 22, "port")
	username := flag.String("u", "root", "username")
	password := flag.String("p", "", "password")
	cmds := flag.String("cmd", "", "command")
	configFile := flag.String("c", "", "config file path")
	key := flag.String("k", "", "ssh private key file")
	ciphers := flag.String("ciphers", "", "ciphers")
	keyExchanges := flag.String("keyExchanges", "", "keyExchanges")
	linuxMode := flag.Bool("l", true, "In linux mode,multi command combine with && ,such as date&&cd /opt&&ls")
	timeout := flag.Int("t", 30, "max timeout")

	flag.Parse()
	f = &Flags{
		Hosts:        *hosts,
		Port:         *port,
		Username:     *username,
		Password:     *password,
		Cmds:         *cmds,
		ConfigFile:   *configFile,
		Key:          *key,
		Ciphers:      *ciphers,
		KeyExchanges: *keyExchanges,
		LinuxMode:    *linuxMode,
		Timeout:      *timeout,
	}
}

func GetArgs() *Flags {
	return f
}
